package com.pactera.madp.cp.controller.oms.prod;

import com.pactera.madp.common.core.util.R;
import com.pactera.madp.common.log.annotation.SysLog;
import com.pactera.madp.cp.api.entity.prod.ProdGroupEntity;
import com.pactera.madp.cp.service.ProdGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 华融湘江产品分类管理
 *
 * @author HuHao
 * @date 2022/3/21 21:31
 */
@RestController
@AllArgsConstructor
@RequestMapping("/prod-group")
@Api(value = "prod-group", tags = "产品分类管理")
public class ProdGroupController {

    @Autowired
    private ProdGroupService prodGroupService;

    @GetMapping("/list")
    @ApiOperation(value = "查询金融小店产品分类列表")
    public R getProdTree(@RequestParam(required = false) Integer status) {
        return R.ok(prodGroupService.getProdGroupTree(status));
    }

    @SysLog("编辑产品分类")
    @PutMapping
    @ApiOperation(value = "编辑产品分类")
    public R update(@RequestBody ProdGroupEntity entity) {
        return R.ok(prodGroupService.updateById(entity));
    }

    @SysLog("批量编辑产品分类")
    @PutMapping("/batch")
    @ApiOperation(value = "批量编辑产品分类")
    public R batch(@RequestBody List<ProdGroupEntity> entites) {
        return R.ok(prodGroupService.updateBatchById(entites));
    }

}
